<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>我的消息</title>
<jsp:include page="../head.jsp" />
<link rel="stylesheet" type="text/css" media="screen" href="<%=path %>/js/jquery.combogrid/resources/css/smoothness/jquery-ui-1.10.1.custom.css"/>
<script type="text/javascript" src="<%=path %>/js/jquery.combogrid/resources/jquery/jquery-ui-1.10.1.custom.min.js"></script>
<link rel="stylesheet" type="text/css" media="screen" href="<%=path %>/js/jquery.combogrid/resources/css/smoothness/jquery.ui.combogrid.css"/>
<script type="text/javascript" src="<%=path %>/js/jquery.combogrid/resources/plugin/jquery.ui.combogrid-1.6.3.js"></script>
<script type="text/javascript">
	
	jQuery(document).ready(function(){
		$( "#receiverSearchStr" ).combogrid({
			url: '<%=path%>/user/userAjax_query4AutoComplete_resourceAction.action',
			debug:false,
	    	//replaceNull: true,
			colModel: [{'columnName':'id','width':'15','label':'编号'}, {'columnName':'name','width':'40','label':'员工姓名'},{'columnName':'departmentName','width':'40','label':'所属部门'}],
			select: function( event, ui ) {
				$("#receiverSearchStr").val(ui.item.name);
				var nameStr=$("#receiverNameStr").val();
				nameStr+=ui.item.name+",";
				var idStr=$("#receiverIdStr").val();
				idStr+=ui.item.id+",";
				$( "#receiverNameStr" ).val(nameStr);
				$( "#receiverIdStr" ).val(idStr);
				return false;
			}
		});
	});

	function save(){
		
		
		if(trim($("#receiverNameStr").val())==""){
			addError("receiverNameStr","接收人不能为空.");
			return;
		}
		if($("#messageContent").val().length>100){
			addError("messageContent","消息内容最多100个字.");
			return;
		}
		if (!checkForm(document.getElementById("saveForm"))) {
			return;
		}
		xbox.load("loading");	
		$("#saveForm").ajaxSubmit(function(){
			parent.j_search(1);
			parent.closeSearchBox();
	    });
	}
	function turnBack(){
		parent.j_search(1);
		parent.closeSearchBox();
	}
	function empty(){
		$("#receiverSearchStr").val("");
		$("#receiverNameStr").val("");
		$("#receiverIdStr").val("");
	}
	

</script>

</head>
<body>
<form action="<%=path%>/message/message_save_senderAction.action" method="post" id="saveForm">
<table width="98%" align="center" border="0" cellpadding="4" cellspacing="1" bgcolor="#F1F1F1" style="margin-bottom:8px">
  <tr bgcolor="#FFFFFF">
    <td colspan="4" height="16"><span></span></td>
  </tr>
  <tr bgcolor="#FFFFFF">
    <td width="10%" align="right" bgcolor="#FFFFFF">接收人搜索：</td>
    <td width="90%" colspan="3" align="left" bgcolor="#FFFFFF">
              <input maxlength="1024" style="width:20%" type="text" name="receiverSearchStr" id="receiverSearchStr" />
              <input type='button' class="btn" style="width:140px;height:30px;" onclick="empty();" value='清空接收人列表' />
    </td>
  </tr>
  <tr bgcolor="#FFFFFF">
    <td width="10%" align="right" bgcolor="#FFFFFF"><span style="color:red;">*</span>接收人列表：</td>
    <td width="90%" colspan="3" align="left" bgcolor="#FFFFFF">
              <input maxlength="1024" style="width:60%" readonly="readonly" type="text" name="receiverNameStr" id="receiverNameStr" value="${receiverNameStr}" />
    </td>
  </tr>
  <tr bgcolor="#FFFFFF">
    <td width="10%" align="right" bgcolor="#FFFFFF"><span style="color:red;">*</span>消息内容：</td>
    <td width="90%" colspan="3" align="left" bgcolor="#FFFFFF">
              <textarea rows="3"  name="message.messageContent" id="messageContent">${message.messageContent}</textarea>
    </td>
  </tr>
  <tr align="right" bgcolor="#F1F1F1">
	<td height="36" colspan="4" align="center">
		<input type='button' class="btn" onclick="save();" value='发送' />
	    &nbsp;<input type='button' class="btn" onclick="turnBack();" value='返回' />
</td>
</tr>
</table>
<input type="hidden" name="receiverIdStr" id="receiverIdStr" value="${receiverIdStr}" />
</form>
	

</body>
</html>
